

//创建文本区域
    lv_obj_t* ta = lv_textarea_create(lv_scr_act());
    //1.添加文本
    lv_textarea_add_char(ta, 'A');
    lv_textarea_add_text(ta, "BCD");
    //2.设置光标位置
    //0:最左侧； LV_TEXTAREA_CURSOR_LAST：最右侧
    lv_textarea_set_cursor_pos(ta, 0);

//删除文本
    //删除光标左侧的一个字符
    lv_textarea_del_char(ta);
    //删除光标右侧的一个字符
    lv_textarea_del_char_forward(ta);

//设置模式
    //当文本过长时，会默认换行，下面的函数只显示在一行上
    lv_textarea_set_one_line(ta, true);
    //密码模式
    lv_textarea_set_password_mode(ta, true);
    //设定密码隐藏时间,单位：ms
    lv_textarea_set_password_show_time(ta, 100);

//限制字符输入
    //只能输入这10个数字
    lv_textarea_set_accepted_chars(ta, "0123456789");
    //输入长度为6，超出在输入没用
    lv_textarea_set_max_length(ta, 6);

//占位符，获取文本，比对文本
        //占位符，提示输入密码
    lv_textarea_set_placeholder_text(ta, "password");
    //获取文本
    const char* txt = lv_textarea_get_text(ta);
    //比对文本内容
    //当s1 = s2时，返回0
    strcmp(txt, "123456");



    /********例子***************** */
static void event_cb(lv_event_t* e)
{
    lv_event_code_t code = lv_event_get_code(e);
    lv_obj_t* target = lv_event_get_target(e);
    if(target == ta)
    {
        if(code == LV_EVENT_FOCUSED) //选中与键盘进行关联
        {
            lv_keyboard_set_textarea(keyboard,ta);
        }
        else if(code == LV_EVENT_VALUE_CHANGED)
        {
            const char* txt = lv_textarea_get_text(ta);
            if(strcmp(txt, "admin") == 0)
                lv_label_set_text(label_user, LV_SYMBOL_OK);
            else
                lv_label_set_text(label_user, "");
        }
    }
    else if(target == ta_password)
    {
        if(code == LV_EVENT_FOCUSED)
        {
            lv_keyboard_set_textarea(keyboard,ta_password);
        }
        else if(code == LV_EVENT_VALUE_CHANGED)
        {
            const char* txt2 = lv_textarea_get_text(ta_password);
            if(strcmp(txt2, "123456") == 0)
                lv_label_set_text(label_password, LV_SYMBOL_OK);
            else
                lv_label_set_text(label_password, "");
        }
    }
}
void my_gui(void)
{
//1.设置用户输入文本框
    ta = lv_textarea_create(lv_scr_act());
    lv_obj_set_size(ta, 300, 40);
    lv_obj_align(ta, LV_ALIGN_TOP_MID, 0, 40);
    lv_obj_remove_style(ta, NULL, LV_PART_SCROLLBAR);
    lv_textarea_set_password_mode(ta, true);
    lv_textarea_set_placeholder_text(ta, "username");
    lv_obj_add_event_cb(ta, event_cb, LV_EVENT_ALL,NULL);
//2.设置密码输入文本框
    ta_password = lv_textarea_create(lv_scr_act());
    lv_obj_set_size(ta_password, 300, 40);
    lv_obj_align_to(ta_password,ta,LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
    lv_obj_remove_style(ta_password, NULL, LV_PART_SCROLLBAR);
    lv_textarea_set_password_mode(ta_password, true);
    lv_textarea_set_placeholder_text(ta_password, "password");
    lv_obj_add_event_cb(ta_password, event_cb, LV_EVENT_ALL,NULL);
//3.创建user标签
    label_user = lv_label_create(lv_scr_act());
    lv_label_set_text(label_user, "");
    lv_obj_set_style_text_font(label_user, &lv_font_montserrat_20, LV_PART_MAIN);
    lv_obj_align_to(label_user,ta, LV_ALIGN_OUT_RIGHT_MID,30,0);
//4.创建password标签
    label_password = lv_label_create(lv_scr_act());
    lv_label_set_text(label_password, "");
    lv_obj_set_style_text_font(label_password, &lv_font_montserrat_20, LV_PART_MAIN);
    lv_obj_align_to(label_password,ta_password, LV_ALIGN_OUT_RIGHT_MID,30,0);
//设置键盘
    keyboard = lv_keyboard_create(lv_scr_act());

}